import 'package:flutter/widgets.dart';
import 'package:flutter_dk_form/flutter_dk_form.dart';
import 'package:flutter_dynamic_forms/flutter_dynamic_forms.dart';

import 'radio.dart' as model;

class RadioRenderer extends FormElementRenderer<model.DyRadio> {
  @override
  Widget render(
      model.DyRadio element,
      BuildContext context,
      FormElementEventDispatcherFunction dispatcher,
      FormElementRendererFunction renderer) {
    return Center(
      child: Padding(
        padding: const EdgeInsets.all(8.0),
        child: DkSwitchFormField(
            initialValue: element.value,
            title: element.title,
            attribute: element.attribute,
            valueTransformer: (val) {
              return val ? 1 : 0;
            }),
      ),
    );
  }
}
